import React from 'react';
import '../css/Login.css';
import eventEmitter from '../event';

class Login extends React.Component{
    constructor(props){
        super(props);
    }
    render(){
        return(
            <div className="login">
                <div className="login-container">
                    <div className="login-top">
                        <div><font>账号登录</font></div>
                        <div>扫码登录</div>
                    </div>
                    <input placeholder="邮箱/手机号码/小米ID" ref="phone" />
                    <input placeholder="密码" ref="password" />
                    <button onClick={()=>{
                        console.log(this.refs.phone);
                        var value = this.refs.phone.value;
                        if(value.length === 0){
                            alert("不能为空！");
                            return;
                        }
                        var password = this.refs.password.value;
                        var login = {
                            content:value,
                            password:password
                        }

                        eventEmitter.emit("sendMessageTooBoard",login);

                        this.props.history.push("/");

                    }}>登录</button>
                </div>
            </div>
        );
    }
    
    componentDidMount(){
        console.log(this);
    }
}

export default Login;